﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using EasyBuildingCMS.BLL.CoreEngine;

namespace EasyBuildingCMS.BuildingBlocks
{
    public partial class BuildingBlockWrapper : System.Web.UI.UserControl
    {
        private int buildingBlockInstanceID;
        public int BuildingBlockInstanceID
        {
            get { return buildingBlockInstanceID; }
            set { buildingBlockInstanceID = value; }
        }

        private string buildingBlockInstanceTitle;
        public string BuildingBlockInstanceTitle
        {
            get { return buildingBlockInstanceTitle; }
            set { buildingBlockInstanceTitle = value; }
        }

        
        public string Mode
        {
            get { return BLL.Globals.Mode; }
        }

        public EasyBuildingCMS.BuildingBlocks.UserControlContainer BuildingBlockControls
        {
            get 
            {
                if (this.UserControlContainer == null)
                {
                    UserControlContainer userControlContainer = (UserControlContainer)this.LoadControl("~/BuildingBlocks/Utility/UserControlContainer.ascx");
                    return userControlContainer;
                }
           
                return this.UserControlContainer;
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            UserControlContainer.BuildingBlockInstanceID = this.BuildingBlockInstanceID;
            
        }

        public void BindBuildingBlockControl(Control control)
        {
            BuildingBlockControls.Controls.Add(control);
        }

        protected void DeleteButton_Click(object sender, EventArgs e)
        {
            BuildingBlockInstanceRepository buildingBlockInstanceRepository = new BuildingBlockInstanceRepository();
            buildingBlockInstanceRepository.DeleteBuildingBlockInstance(this.buildingBlockInstanceID);
            ((Default)this.Page).LoadPageContent((int)(BLL.Helper.ToInt(BLL.Globals.CurrentPage)));
         
        }

        

    }
}